﻿//作业:1、定义平面上的球, 求两个球之间的距离
#include <iostream>
#include <cmath>
using namespace std;
//定义圆Circle类
class Circle {
private:
	double x , y;
public:
	Circle() {
		cout << "请输入中心坐标（x，y）： " << endl;	//提示输入圆心坐标
		cin >> x >> y ;
		cout << "中心坐标：" << "(" << x << "," << y <<")"  << endl;	//显示圆的坐标
	}
	//设置全局函数distance做友元
	friend double distance(Circle& c1, Circle& c2);
};
/* distance函数：计算两圆圆心距离 */
double distance(Circle& c1, Circle& c2) {
	double d;
	d = sqrt((c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y));//两点距离公式求距离，公式为d = √[(x2 - x1)² + (y2 - y1)²]
	return d;
}
int main()
{
	Circle c1, c2;
	distance(c1, c2);	
	cout << "两个圆的距离是 " << distance(c1, c2) << endl;
	return 0;
}

